﻿using wwl.Contract.Dtos.Requests.Rbac;
using wwl.Domain.Entities.Rbac;

namespace wwl.Test
{
  public class TenantTestDataBuilder
  {
    private string _id = Guid.NewGuid().ToString();
    private string _tenantCode = "TEST001";
    private string _tenantName = "测试租户";
    private TenantStatus _status = TenantStatus.ENABLED;
    private string _createdBy = "test-user";
    private string _remarks = "测试备注";

    public TenantTestDataBuilder WithId(string id)
    {
      _id = id;
      return this;
    }

    public TenantTestDataBuilder WithTenantCode(string code)
    {
      _tenantCode = code;
      return this;
    }

    public TenantTestDataBuilder WithTenantName(string name)
    {
      _tenantName = name;
      return this;
    }

    public TenantTestDataBuilder WithStatus(TenantStatus status)
    {
      _status = status;
      return this;
    }

    public TenantTestDataBuilder WithCreatedBy(string createdBy)
    {
      _createdBy = createdBy;
      return this;
    }

    public Tenant BuildEntity()
    {
      return new Tenant
      {
        Id = _id,
        TenantCode = _tenantCode,
        TenantName = _tenantName,
        Status = _status,
        CreatedBy = _createdBy,
        Remarks = _remarks,
        CreatedTime = DateTime.UtcNow,
        UpdatedTime = DateTime.UtcNow
      };
    }

    public CreateTenantRequest BuildCreateRequest()
    {
      return new CreateTenantRequest
      {
        TenantCode = _tenantCode,
        TenantName = _tenantName,
        Remarks = _remarks
      };
    }

    public UpdateTenantRequest BuildUpdateRequest()
    {
      return new UpdateTenantRequest
      {
        TenantName = _tenantName,
        Status = _status.ToString(),
        Remarks = _remarks
      };
    }
  }
}